<template>
	<!-- 检测数据 -->
	<view>
		<view class="search">
			<input type="text" v-model="searchValue" placeholder="请输入搜索的内容" />
			<text @click="C_search">搜索</text>
		</view>
		<view class="title">{{title}}</view>
		<view class="list">
			<view v-for="(item,index) in list" :key="item" @click="C_listItem(item)">
				<view class="tit">【{{item.name}}】</view>
				<view class="subtit">{{item.intro}}</view>
			</view>
		</view>
		<!-- #ifdef H5 || MP-WEIXIN -->
		<button type="default" open-type="contact">
			<view class="kefu">
				<image :src="vuex_httpImageUrl && vuex_httpImageUrl+'static/common/kefu.png'" class="avatar"></image>
			</view>
		</button>
		<!-- #endif -->
		
		<!-- #ifdef APP-PLUS -->

		<button type="default" @click="makePhone">
			<view class="kefu">
				<image :src="vuex_httpImageUrl && vuex_httpImageUrl+'static/common/kefu.png'" class="avatar"></image>
			</view>
		</button>
		<!-- #endif -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				status: null,
				list: [],
				isShow: false,
				title: '',

				searchValue: ''
			}
		},
		onLoad(o) {
			this.status = o.status
			uni.setNavigationBarTitle({
				title: o.status == 1 ? '检测数据' : '中药查询'
			})
			this.def_list(o.status)
		},
		methods: {
			makePhone(){
				console.log('打电话');
				
					let that = this;
					uni.showModal({
					
						content: '是否拨打电话?',
						success: res => {
							if (res.confirm){
								
									uni.makePhoneCall({
										phoneNumber: '13718124230',
										fail(e) {
											close('shibai',e)
										}
									});
							}
						}
					})
					
			},
			async def_list(status) {
				let result = status == 1 ? await this.$u.api.indexmedicalResults() : await this.$u.api.indexinfotcm();
				this.title = result.msg
				// this.list = status == 1 ? result.data.list : result.data
				this.list = result.data.list
				console.log(result, 'result');
			},
			async C_search() {
				let params = {
					page: 1,
					keyword: this.searchValue
				}
				let searchResult = this.status == 1 ? await this.$u.api.indexmedicalResults(params) : await this.$u.api
					.indexinfotcm(params);
				this.list = searchResult.data.list
				console.log(searchResult);
			},
			C_listItem(item) {
				uni.navigateTo({
					url: './detail/detail?en_db=' + encodeURIComponent(JSON.stringify(item))
				})
			},
			C_kefu() {
				this.isShow = true
			}
		}
	}
</script>
<style lang="scss">
	page {
		background-color: #FFFFFF;
		border-top: 1px solid #F1F1F1;
		padding: 30rpx;
		box-sizing: border-box;

		.search {
			display: flex;
			align-items: center;

			input {
				flex: 1;
				background-color: #F9F9F9;
				border-radius: 70rpx;
				border: 1px solid #DCDCDC;
				padding-left: 70rpx;
				height: 70rpx;
				background-image: url($http-image-url+"static/common/icon_search.png");
				background-size: 35rpx;
				background-position: 20rpx center;
				background-repeat: no-repeat;
			}

			text {
				width: 80rpx;
				text-align: right;
			}
		}

		.title {
			font-size: 45rpx;
			text-align: center;
			margin: 30rpx;
			color: #333333;
			font-weight: bold;
		}

		.list {
			>view {
				margin-bottom: 50rpx;

				.tit {
					font-weight: bold;
					font-size: 35rpx;
					margin-bottom: 20rpx;
				}

				.subtit {
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					line-height: 50rpx;
				}
			}
		}

		.kefu {
			width: 260rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			position: fixed;
			bottom: 15%;
			right: 0rpx;

			.avatar {
				width: 80rpx;
				height: 80rpx;
			}

			.content {
				text-align: center;
				background-color: #FBF8EF;
				border: 1px solid #FACD89;
				border-radius: 30rpx;
				padding: 15rpx 30rpx;
				box-sizing: border-box;
				border-bottom: 2px solid #FACD89;

				text {
					display: inline-block;
					color: #FFFFFF;
					background-color: #C88D33;
					padding: 5rpx 20rpx;
					border-radius: 10rpx;
					margin-top: 15rpx;
				}
			}

			.close {
				margin-top: 20rpx;
				width: 50rpx;
				height: 50rpx;
			}
		}
	}
</style>
